﻿using CPPEI.Coolzon.Common;
using CPPEI.Coolzon.Event.NCL;
using CPPEI.Coolzon.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.DisplayApp
{
    public partial class MainWindow
    {
        [Subscribe]
        public void OnReceiveNCLShowLaserPointerEvent(NCLShowLaserPointerEvent @event)
        {
            if(@event.State != NCLEventState.Finished)
            {
                return;
            }

            if(@event.IsEnable == false)
            {
                ExternalApp.LaserPointApp.Instance.SendHide();
            }
            else
            {
                double x = @event.DestPointX;
                double y = @event.DestPointY;

                System.Windows.Point ptInScreen = new System.Windows.Point(x, y);
                this.Dispatcher.Invoke(() =>
                {
                    // 转换为屏幕坐标
                    ptInScreen = this.PointToScreen(ptInScreen);
                });

                ExternalApp.LaserPointApp.Instance.SendShow(ptInScreen.X, ptInScreen.Y);
            }
        }
    }
}
